home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 578 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.2 KB  |  68 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: Etay_Bogner@mail.stil.scitex.com (Etay Bogner)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Calling X(int) from X()'s init list
  5. Date: 28 Feb 1996 16:16:46 GMT
  6. Organization: Scitex Corp.
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <Etay_Bogner-2802961057120001@metay.stil.scitex.com>
  9. References: <4gnush$phg@news.kth.se> <4gognf$et@news.bridge.net> <4gsa2r$gjm@sdaw04.seinf.abb.se> <Etay_Bogner-2702961023450001@metay.stil.scitex.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Content-Type: text
  12. X-Nntp-Posting-Host: metay.scitex.com
  13. Content-Length: 1220
  14. X-Lines: 43
  15. Originator: clamage@taumet
  16.  
  17. In article <Etay_Bogner-2702961023450001@metay.stil.scitex.com>,
  18. Etay_Bogner@mail.stil.scitex.com (Etay Bogner) wrote:
  19. << My inclination, although I rarly use const or reference data members, will
  20. << be to wrap those data members in an internal structure with it's own
  21. << constructor :
  22. << 
  23. << class A_Class_With_A_Const_Or_Refs {
  24. <<     A_Class_With_A_Const_Or_Refs(long& l);
  25. <<     struct internal_Data {
  26. <<         long& mLong;
  27. <<         const long mClassID; // when there was no RTTI, for instance
  28. <<         internal_Data(long& inLong, const long inID);
  29. <<         } mInternalData;
  30. <<     };
  31. << 
  32. << A_Class_With_A_Const_Or_Refs::A_Class_With_A_Const_Or_Refs(long& l) :
  33. << mInternalData(l, 'MYID') {}
  34. << 
  35. << and so on.
  36.  
  37. I think it may be unclear :
  38.  
  39. my suggestion is that one can write a *lot* of constructors, and they can
  40. call the internal constructor, which has the same effect as calling :
  41.  
  42. class X {
  43.     X(long);
  44.     X(char*);
  45.     };
  46.  
  47. X::X(char* c) : X(1) {}
  48.  
  49. Which is the desired behavior.
  50.  
  51. -- 
  52. -- Etay Bogner
  53. -- Etay_Bogner@mail.stil.scitex.com
  54. -- Scitex Corp.
  55. -- Israel.
  56. -- 
  57. -- There are two rules for success in life:                   
  58. -- Rule 1:  Don't tell people everything you know.                
  59. -- 
  60.  
  61.  
  62. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your
  63.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  64.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  65.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  66.   Comments? mailto:std-c++-request@ncar.ucar.edu
  67. ]
  68.